#!/bin/python
#coding: utf-8
import pika
import json

class RabbitMQ():
    def __init__(self, id,filelist):
        print("开始连接rabbitmq")
        credentials = pika.PlainCredentials('admin', '123456')
        connection = pika.BlockingConnection(pika.ConnectionParameters(host = 'cad_rabbitmq',port = 5672,virtual_host = '/',credentials = credentials))
        channel = connection.channel()
        channel.queue_declare(queue = 'python-test', durable = False)
        print("连接成功")
        channel.basic_publish(exchange = '',routing_key = 'python-test',body = json.dumps({"id":id,"filelist":filelist}))
        print("发送成功")

if __name__ == "__main__":
    yun_pian = RabbitMQ(1,["bde.dwg"])
